home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 24
/
Aminet 24 (1998)(GTI - Schatztruhe)[!][Apr 1998].iso
/
Aminet
/
dev
/
c
/
AmiVoGL_MDEV.lha
/
examples
/
balls.c.bak
< prev
next >
Wrap
Text File
|
1997-12-26
|
3KB
|
182 lines
#include <stdio.h>
#ifdef SGI
#include "gl.h"
#include "device.h"
#include "hershey.h"
#else
#include "vogl.h"
#include "vodevice.h"
#endif
#ifndef PI
#define PI 3.1415926535
#endif
#ifndef TC
#include <math.h>
#else
extern double sin(), cos();
#endif
#define RADIUS 10.0
#define SPHERE 1L
/* ---------------------------------------------------------------------
* Prototypes:
*/
void makesphere(void); /* balls.c */
int main(void); /* balls.c */
/* --------------------------------------------------------------------- */
/*
* makesphere
*
* make a sphere object
*/
void makesphere(void)
{
float r, z;
int i, a;
makeobj(SPHERE);
/*
* create the latitudinal rings
*/
for (i = 0; i < 1800; i += 200) {
pushmatrix();
rotate(i, 'y');
circ(0.0, 0.0, RADIUS);
popmatrix();
}
/*
* create the longitudinal rings
*/
pushmatrix();
rotate(900, 'x');
for (a = -900; a < 900; a += 200) {
r = RADIUS * cos((double)a * PI / 180.0);
z = RADIUS * sin((double)a * PI / 180.0);
pushmatrix();
translate(0.0, 0.0, -z);
circ(0.0, 0.0, r);
popmatrix();
}
popmatrix();
closeobj();
}
/*
* a demonstration of objects
*/
int main(void)
{
short val;
winopen("balls");
hfont("times.rb");
unqdevice(INPUTCHANGE);
qdevice(KEYBD);
/*
* set up our viewing transformation
*/
perspective(900, 1.0, 0.001, 500.0);
lookat(13.0, 13.0, 8.0, 0.0, 0.0, 0.0, 0);
color(BLACK);
clear();
/*
* Call a routine to make the sphere object
*/
makesphere();
/*
* Now draw the sphere object scaled down. We use the pushmatrix
* and the popmatrix to preserve the transformation matrix so
* that only this sphere is drawn scaled.
*/
color(CYAN);
ortho2(0.0, 1.0, 0.0, 1.0);
hcentertext(1);
htextsize(0.08, 0.15);
move2(0.6, 0.3);
htextang(-90.0);
hcharstr("1st rule...");
pushmatrix();
scale(0.5, 0.5, 0.5);
callobj(SPHERE);
popmatrix();
/*
* now we draw the same sphere translated, with a different
* scale and color.
*/
color(WHITE);
pushmatrix();
translate(0.0, -1.4 * RADIUS, 1.4 * RADIUS);
scale(0.7, 0.4, 0.3);
callobj(SPHERE);
popmatrix();
/*
* and maybe a few more times....
*/
color(RED);
pushmatrix();
translate(0.0, RADIUS, 0.7 * RADIUS);
scale(0.2, 0.2, 0.2);
callobj(SPHERE);
popmatrix();
color(GREEN);
pushmatrix();
translate(0.0, 1.5 * RADIUS, -RADIUS);
scale(0.15, 0.15, 0.15);
callobj(SPHERE);
popmatrix();
color(YELLOW);
pushmatrix();
translate(0.0, -RADIUS, -RADIUS);
scale(0.12, 0.12, 0.12);
callobj(SPHERE);
popmatrix();
color(BLUE);
pushmatrix();
translate(0.0, -2.0*RADIUS, -RADIUS);
scale(0.3, 0.3, 0.3);
callobj(SPHERE);
popmatrix();
ortho2(0.0, 1.0, 0.0, 1.0);
hcentertext(1);
htextsize(0.08, 0.15);
move2(0.8, 0.5);
htextang(-90.0);
hcharstr("I'm very ordinary!");
move2(0.8, 0.5);
htextang(-37.0);
hcharstr("I'm a fucking dude!");
qread(&val);
gexit();
}